#!/bin/bash

# Method of use

# UserParameter=nginx.status[*],/usr/local/zabbix/script/nginx_status.sh $1

HOST="127.0.0.1"

PORT="80"

URL="http://${HOST}:${PORT}/nginx_status"

active() {
	curl "${URL}" 2>/dev/null | grep  "Active" | awk '{print $NF}'
}

reading() {
	curl "${URL}" 2>/dev/null | grep "Reading" | awk '{print $2}'
}

writing() {
	curl "${URL}" 2>/dev/null | grep "Writing" | awk '{print $4}'
}

waiting() {
	curl "${URL}" 2>/dev/null | grep "Waiting" | awk '{print $NF}'
}

accepts() {
	curl "${URL}" 2>/dev/null | awk NR==3 | awk '{print $1}'
}

handled() {
	curl "${URL}" 2>/dev/null | awk NR==3 | awk '{print $2}'
}

requests() {
	curl "${URL}" 2>/dev/null | awk NR==3 | awk '{print $NF}'
}

ping() {
	ps -ef | grep nginx | grep -v grep -c
}

$1